import { registerUI, Rect } from "@leafer-ui/core";
import type { IRectInputData } from '@leafer-ui/interface';

export interface ICustomInputData extends IRectInputData {
    colloderInfo?: {
        type: string;
        instance?: any;
    };
}

@registerUI()
export class Collider extends Rect {
    public get __tag() { return 'Collider' }
    static elements: Array<any> = []
    private _type: string;
    constructor({ colloderInfo, ...res }: ICustomInputData) {
        super({stroke: 'red', ...res})
        this._type = colloderInfo?.type ?? 'normal';
        if (colloderInfo?.instance) {
            Collider.elements.push(colloderInfo?.instance)
        }
    }

    get type() {
        return this._type;
    }

    static staticColliders = () => {
        return Collider.elements.filter((c) => c.collider.type === 'static')
    }
}